package com.key.oa.activity;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.key.keyleaderoa.R;
import com.key.oa.util.Util;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ListViewAdapter extends BaseAdapter {
		
	public List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
	private LayoutInflater inflater = null;

	public ListViewAdapter(Context context, List<Map<String, Object>> items) {
		this.list = items;
		inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	public int getCount() {
		return list.size();
	}

	public Object getItem(int position) {
		return list.get(position);
	}

	public long getItemId(int position) {
		return position;
	}

	public View getView( int position, View view, ViewGroup parent ) {
		if (view == null) {
			view = inflater.inflate(R.layout.key_item, null);
		}
		TextView time = (TextView) view.findViewById(R.id.time);
		TextView content = (TextView) view.findViewById(R.id.content);
		TextView department = (TextView) view.findViewById(R.id.department);
		TextView name = (TextView) view.findViewById(R.id.name);
		TextView budget = (TextView) view.findViewById(R.id.budget);
		
		time.setText((String)Util.uncheckdata.get(position).getUnchecked("StartTime"));
        budget.setText((String)Util.uncheckdata.get(position).getUnchecked("cost_budget"));
        content.setText((String)Util.uncheckdata.get(position).getUnchecked("Classfication"));
        department.setText((String)Util.uncheckdata.get(position).getUnchecked("depname"));
        name.setText((String)Util.uncheckdata.get(position).getUnchecked("name"));
		
		return view;
	}
}
